package com.jiazhong.basic.atm.dao;

import com.jiazhong.basic.atm.bean.TradeLog;
import com.jiazhong.basic.atm.db.DBManager;
import lombok.SneakyThrows;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class TradeLogDAO {

    private Connection conn;
    private PreparedStatement ps;

    @SneakyThrows
    public int save(TradeLog tradeLog) {
        conn = DBManager.getConnection();
        String sql = "insert into tradeLog values(null,?,now(),?,?,?,?)";
        ps = conn.prepareStatement(sql);
        ps.setString(1, tradeLog.getCardId());
        ps.setInt(2, tradeLog.getTradeId());
        ps.setDouble(3, tradeLog.getTradeMoney());
        ps.setString(4, tradeLog.getOtherCardId());
        ps.setString(5, tradeLog.getDesc());
        return ps.executeUpdate();
    }
}
